package com.xmb.wechat.view.alipay;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.widget.ImageView;
import android.widget.TextView;

import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.util.PicLoadUtils;

import butterknife.BindView;

/**
 * @Author lijiangop
 * @CreateTime 2020/5/22 15:50
 */
public class AliPayYEBDetailActivity extends BaseActivity {

    @BindView(R2.id.iv_bg)
    ImageView mIvBg;
    @BindView(R2.id.tv_money)
    TextView  mTvMoney;
    @BindView(R2.id.tv_earnings)
    TextView  mTvEarnings;
    @BindView(R2.id.tv_total_earnings)
    TextView  mTvTotalEarnings;
    @BindView(R2.id.tv_seven_nh)
    TextView  mTvSevenNh;

    public AliPayYEBDetailActivity() {
        super(R.layout.activity_alipay_yeb_detail);
        isChangeStatusBarTxtColor = false;
    }

    public static void start(Activity activity, String screenShot, String balance, String yEarnings, String tEarnings, String sevenNh) {
        Intent intent = new Intent(activity, AliPayYEBDetailActivity.class);
        intent.putExtra("screenShot", screenShot);
        intent.putExtra("balance", balance);
        intent.putExtra("yEarnings", yEarnings);
        intent.putExtra("tEarnings", tEarnings);
        intent.putExtra("sevenNh", sevenNh);
        activity.startActivity(intent);
    }

    @Override
    protected void initView() {
        setStatusBarColor(Color.parseColor("#b04700"));
        setNavigationColor(Color.parseColor("#fcfcfc"));

        String screenShot = getIntent().getStringExtra("screenShot");
        String balance = getIntent().getStringExtra("balance");
        String yEarnings = getIntent().getStringExtra("yEarnings");
        String tEarnings = getIntent().getStringExtra("tEarnings");
        String sevenNh = getIntent().getStringExtra("sevenNh");
        //show view
        if (!TextUtils.isEmpty(screenShot))
            PicLoadUtils.loadSdcardPic(screenShot, mIvBg);
        if (!TextUtils.isEmpty(balance))
            mTvMoney.setText(balance);
        if (!TextUtils.isEmpty(yEarnings)) {
            SpannableString spannableString = new SpannableString("昨日收益 " + yEarnings + " 元");
            spannableString.setSpan(new RelativeSizeSpan(1.3f), 4, 5 + yEarnings.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#ff6700")), 4, 5 + yEarnings.length(), Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
            mTvEarnings.setText(spannableString);
        }
        if (!TextUtils.isEmpty(tEarnings))
            mTvTotalEarnings.setText(tEarnings);
        if (!TextUtils.isEmpty(sevenNh))
            mTvSevenNh.setText(sevenNh);
        //change font
        Typeface fromAsset = Typeface.createFromAsset(getAssets(), "fonts/alipay_number.ttf");
        if (fromAsset != null)
            mTvMoney.setTypeface(fromAsset);
        if (fromAsset != null)
            mTvEarnings.setTypeface(fromAsset);
        if (fromAsset != null)
            mTvTotalEarnings.setTypeface(fromAsset);
        if (fromAsset != null)
            mTvSevenNh.setTypeface(fromAsset);
    }
}
